package com.xing.config.ds.rw.common;

import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;

/**
 * Created by Bradish7Y on 2017/8/31.
 */
@Slf4j
public class DynamicDataSource extends AbstractRoutingDataSource {

    /**
     * 取得当前使用哪个数据源
     *
     * @return
     */
    @Override
    protected Object determineCurrentLookupKey() {
        log.info("datasource:{}", DbContextHolder.getDbType());
        return DbContextHolder.getDbType();
    }
}
